package com.iscas.tech.param;

/**
 * 分页参数
 */
public class PageParam {
    /**
     * 页码
     */
    private Integer pageIndex = 1;
    /**
     * 页大小
     */
    private Integer pageSize = 10;
    /**
     * 偏移量
     */
    private Long offset;

    public Integer getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(Integer pageIndex) {
        if (pageIndex < 1) {
            return;
        }
        this.pageIndex = pageIndex;
        setOffset((long) ((pageIndex - 1) * getPageSize()));
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        if (pageSize < 1) {
            return;
        }
        this.pageSize = pageSize;
        setOffset((long) (getPageIndex() - 1) * pageSize);
    }

    public Long getOffset() {
        return offset;
    }

    public void setOffset(Long offset) {
        this.offset = offset;
    }
}
